﻿package mortal.game.view.copy.groupCopy.view
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.core.*;

    public class FirstBloodRewardPanel extends GSprite
    {
        private var _firstBloodBg:GImageBitmap;
        private var _firstBloodGetBtn:GLoadingButton;
        private var _firstBloodItem:BaseItem;
        private var _type:int;
        private var _copyCode:int;

        public function FirstBloodRewardPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._firstBloodBg = UIFactory.gImageBitmap(ImagesConst.CopyFirstKill_short, 0, 0, this);
            this._firstBloodItem = UICompomentPool.getUICompoment(BaseItem);
            this._firstBloodItem.setItemStyle(ItemStyleConst.Small);
            this._firstBloodItem.x = 30;
            this._firstBloodItem.y = 25;
            this._firstBloodItem.configEventListener(MouseEvent.CLICK, this.getFirstBloodReward);
            this.addChild(this._firstBloodItem);
            this._firstBloodGetBtn = UIFactory.gLoadingButton(ResFileConst.FirstBloodGetBtn, 25, 67, 51, 23, this);
            this._firstBloodGetBtn.drawNow();
            this._firstBloodGetBtn.configEventListener(MouseEvent.CLICK, this.getFirstBloodReward);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._firstBloodBg.dispose(param1);
            this._firstBloodBg = null;
            this._firstBloodItem.dispose(param1);
            this._firstBloodItem = null;
            this._firstBloodGetBtn.dispose(param1);
            this._firstBloodGetBtn = null;
            return;
        }// end function

        public function setBg(param1:int, param2:int, param3:String = "CopyFirstKill_long") : void
        {
            return;
        }// end function

        public function setBgTxt(param1:int, param2:int, param3:String = "CopyFirstKill_Txt") : void
        {
            return;
        }// end function

        public function setBtn(param1:int, param2:int) : void
        {
            return;
        }// end function

        public function setItem(param1:int, param2:int) : void
        {
            return;
        }// end function

        public function set copyCode(param1:int) : void
        {
            this._copyCode = param1;
            return;
        }// end function

        public function set type(param1:int) : void
        {
            this._type = param1;
            if (param1 == ECopyFBType._ECopyFBTypeNotGet)
            {
                EffectManager.glowFilterReg(this._firstBloodItem);
                EffectManager.glowFilterReg(this._firstBloodGetBtn);
                this._firstBloodGetBtn.filterEnabled = true;
            }
            else
            {
                EffectManager.glowFilterUnReg(this._firstBloodItem);
                EffectManager.glowFilterUnReg(this._firstBloodGetBtn);
                this._firstBloodGetBtn.filterEnabled = false;
            }
            var _loc_2:* = ItemConfig.instance.getConfig(int(CopyConfig.instance.getCopyFirstBloodInfoByCode(this._copyCode).firstBloodReward)) as ItemGiftBagInfo;
            var _loc_3:* = _loc_2.itemList1.split("&");
            var _loc_4:* = _loc_3[0].split("#");
            this._firstBloodItem.itemData = new ItemData(int(_loc_4[1]));
            this._firstBloodItem.amount = int(_loc_4[2]);
            return;
        }// end function

        private function getFirstBloodReward(event:MouseEvent) : void
        {
            if (this._type == ECopyFBType._ECopyFBTypeNotGet)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.CopyFirstRewardGet, {code:this._copyCode, item:this._firstBloodItem}));
            }
            else
            {
                MsgManager.showRollTipsMsg("" + Language.getString(70886), MsgRollTipsType.msgRollTips3);
            }
            return;
        }// end function

    }
}
